package com.adderis.soft.domain.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @author Reda
 * @version 1.0
 * @created 20-avr.-2014 22:47:44
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "cas", catalog = "adderis")
public class Cas implements java.io.Serializable {

	private int casid;
	private String cas;
	private Date createtimestamp;
	private String statutcode;
	private Date updatetimesstamp;
	private Date deletiontimesstamp;
	private Set<NomCommercial> nomCommercials = new HashSet<NomCommercial>(0);

	public Cas() {
	}

	public Cas(int casid) {
		this.casid = casid;
	}

	public Cas(int casid, String cas) {
		this.casid = casid;
		this.cas = cas;
	}

	public Cas(String cas, Set<NomCommercial> nomCommercials) {
		super();
		this.cas = cas;
		this.nomCommercials = nomCommercials;
	}

	@Column(name = "createdatetime")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreatetimestamp() {
		return createtimestamp;
	}

	public void setCreatetimestamp(Date createtimestamp) {
		this.createtimestamp = createtimestamp;
	}

	@Column(name = "statutcode", length = 10)
	public String getStatutcode() {
		return statutcode;
	}

	public void setStatutcode(String statutcode) {
		this.statutcode = statutcode;
	}

	@Column(name = "updatedatetime")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getUpdatetimesstamp() {
		return updatetimesstamp;
	}

	public void setUpdatetimesstamp(Date updatetimesstamp) {
		this.updatetimesstamp = updatetimesstamp;
	}

	@Column(name = "deletiondatetime")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getDeletiontimesstamp() {
		return deletiontimesstamp;
	}

	public void setDeletiontimesstamp(Date deletiontimesstamp) {
		this.deletiontimesstamp = deletiontimesstamp;
	}

	@Id
	@Column(name = "cASID", unique = true, nullable = false)
	public int getCasid() {
		return this.casid;
	}

	public void setCasid(int casid) {
		this.casid = casid;
	}

	@Column(name = "Cas", length = 100)
	public String getCas() {
		return this.cas;
	}

	public void setCas(String cas) {
		this.cas = cas;
	}

	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinTable(name = "joinnomcommercialtocas", catalog = "adderis", joinColumns = { @JoinColumn(name = "cASID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "	nomCommercialID", nullable = false, updatable = false) })
	public Set<NomCommercial> getNomCommercials() {
		return nomCommercials;
	}

	public void setNomCommercials(Set<NomCommercial> nomCommercials) {
		this.nomCommercials = nomCommercials;
	}

}
